package com.unieagle.exam.utils;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashSet;
import java.util.Set;

import android.os.Bundle;

public class HttpUtils
{
    private final static String HOST = "http://unieagle.net:4000";

    private final static String EXAM = HOST + "/api/exam.json";
    
    private final static String UPDATE_SUBJECT_QUESTION = HOST + "/api/questions/update_questions";
    
    private final static String SHARE = HOST + "/share";
    
    private static String getUrl(String url, Bundle param)
    {
        Set<String> keyset = param.keySet();
        StringBuilder sb = new StringBuilder(url);
        sb.append("?");
        try
        {
            for (String key : keyset)
            {

                sb.append(key).append("=").append(URLEncoder.encode(param.get(key).toString(), "utf-8")).append("&");
            }
        }
        catch (UnsupportedEncodingException e)
        {
            e.printStackTrace();
            return null;
        }
        sb.deleteCharAt(sb.length() - 1);
        return sb.toString();
    }
    
    public static String getHost() {
    	return HOST;
    }
    
    public static String getExamUrl() {
    	return EXAM;
    }
    
    public static String getUpdateSubjectAndQuestionUrl() {
    	return UPDATE_SUBJECT_QUESTION;
    }
    
    public static String getShareUrl() {
    	return SHARE;
    }
    
}
